﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using ZLDC.Common.Estate;

namespace ZLDC.Topo.BLL.Estate
{
                public class ChangecustomerLogBLL
    {
                                                                public static string p_changecustomerlog_list(int page, int pagesize, string condition)
        {
            DataTable dt = null;
            int total = 0;                       int pageall = 0;         
            using (_Database db = new _Database("estate"))
            {
                dt = ZLDC.DAL.Estate.ChangecustomerLogDAL.p_changecustomerlog_list_table(page, pagesize, condition, ref total, db);
            }

            pageall = _Utility.GetPageAll(pagesize, total);      
            _Json json = new _Json(dt, "");
            return "{page:{currentpage:'" + page + "',pagesize:'" + pagesize + "',total:'" + total + "',pageall:'" + pageall + "'},record:" + json.ToJson() + "}";
        }

                                                public static string p_changecustomerlog_check(int id, out int cid)
        {
            string outmsg = "";
            cid = 0;

            using (_Database db = new _Database("estate"))
            {
                ZLDC.DAL.Estate.ChangecustomerLogDAL.p_changecustomerlog_check(id, out outmsg, out cid, db);
            }

            return outmsg;
        }

                                                                public static string p_changecustomerlog_change(int typeid, int id, out int cid)
        {
            string outmsg = "";
            cid = 0;

            using (_Database db = new _Database("estate"))
            {
                ZLDC.DAL.Estate.ChangecustomerLogDAL.p_changecustomerlog_change(typeid, id, out outmsg, out cid, db);
            }

            return outmsg;
        }        

                                public static string p_changeCustomer_log_save(int ID, int CId, int changeDeptId, string changeDept, int changeUserId, string changeUser, int acceptDeptId, string acceptDept, int acceptUserId, string acceptUser, int status)
        {
            string outmsg = "";
            int newid = 0;

            using (_Database db = new _Database("estate"))
            {
                ZLDC.DAL.Estate.ChangecustomerLogDAL.p_changeCustomer_log_save(ID, CId, changeDeptId, changeDept, changeUserId, changeUser, acceptDeptId, acceptDept,
                    acceptUserId, acceptUser, status, out outmsg, out newid, db);
            }

            return outmsg;
        }

                public static string UpdateCustomerCheckList(int isself,int mark1,int id) 
        {
            string outmsg = "";
            int rows = 0;
            using (_Database db = new _Database("estate")) 
            {
               rows= ZLDC.DAL.Estate.ChangecustomerLogDAL.UpdateCustomerCheckList(isself, mark1, id,db);
            }
            if (rows > 0)
            {
                outmsg = "审核通过";
            }
            else 
            {
                outmsg = "审核失败";
            }
            return outmsg;
        }

                                                                public static string UpdateCustomerCheckList(int isself, int mark1, int id, int ownerid, string owner, int ownerdeptid, string ownerdept)
        {
            string outmsg = "";
            int rows = 0;
            using (_Database db = new _Database("estate"))
            {
                rows = ZLDC.DAL.Estate.ChangecustomerLogDAL.UpdateCustomerCheckList(isself, mark1, id, ownerid, owner, ownerdeptid, ownerdept, db);
            }
            if (rows > 0)
            {
                outmsg = "审核通过";
            }
            else
            {
                outmsg = "审核失败";
            }
            return outmsg;
        }

                                                                public static int p_customer_ischange_public(int sessionUserId, int customerId, out string outmsg)
        {            
            int newid = 0;

            using (_Database db = new _Database("estate"))
            {
                newid = ZLDC.DAL.Estate.ChangecustomerLogDAL.p_customer_ischange_public(sessionUserId, customerId, out outmsg, db);                    
            }

            return newid;
        }

        public static  DataTable p_CustomerChangelog_ChangeUserId(int id) 
        {
            using (_Database db = new _Database("estate")) 
            {
                return ZLDC.DAL.Estate.ChangecustomerLogDAL.p_CustomerChangelog_ChangeUserId(id, db);
            }
        }

    }
}
